<?php
	include('../config.ini.php');
	include('../function/function.php');
	
	$name = ($_POST['name']); 
	$email = $_POST['email']; 
	$tel = $_POST['tel'];
	
	$to      = CONTACT_EMAIL;
	
	$product_id = $_POST['product_id'];
	$siteurl = SITEURL;
    
	$con = db_connect();
	$sql = "SELECT * FROM products WHERE product_id=$product_id";
	$result = mysql_query($sql);
	$row = mysql_fetch_assoc($result);
	
	$product_title = $row['product_title'];
	$img = $row['product_img'];
	$img2 = $row['product_img_2'];
	$img3 = $row['product_img_3'];
	$img4 = $row['product_img_4'];
	
	$width = $row['product_width'];
	$depth = $row['product_depth'];
	$height = $row['product_height'];
	
	$product_detail = $row['product_detail'];
	
	$subject = 'Pathom Furniture : Order';
	$message = <<<msg
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Pathom Furniture (1994) &amp; Pathom Interior Contract</title>
        
        <link rel="stylesheet" type="text/css" href="{$siteurl}css/reset.css" />
        <link rel="stylesheet" type="text/css" href="{$siteurl}css/order.css" />
	
        <!--[if IE 6]>
	<link href="{$siteurl}css/order_ie6.css" rel="stylesheet" />
	<script language="javascript" type="text/javascript" src="{$siteurl}js/DD_belatedPNG_0.0.8a-min.js"></script>
	<script>
	    DD_belatedPNG.fix('img');
	    DD_belatedPNG.fix('.png_bg');
	</script>
        <![endif]-->
        <!--[if IE 7]>
	<link href="{$siteurl}css/order_ie7.css" rel="stylesheet" />
        <![endif]-->
    </head>
    <body>
        <div id="wrapper">
            <div class="box_top">&nbsp;</div>
            <div id="product_img" class="box_middle">
                <div id="product_img_">
                    <img src="{$siteurl}images/products/{$product_id}/{$img}" alt="{$product_title}"/>
                </div>
                <div id="product_img_thumb">
                    <img src="{$siteurl}images/products/{$product_id}/{$img2}" alt="{$product_title}" class="img_first"/>
                    <img src="{$siteurl}images/products/{$product_id}/{$img3}" alt="{$product_title}" class="img_first"/>
                    <img src="{$siteurl}images/products/{$product_id}/{$img4}" alt="{$product_title}"/>
                </div>
                <div class="clear">&nbsp;</div>
                <div id="product_name">
                    {$product_title}
                </div>
            </div>
            <div class="box_bottom">&nbsp;</div>
            
            <div class="box_top">&nbsp;</div>
            <div id="product_detail" class="box_middle">
                <div id="product_dimension">
                    <table>
                        <tr>
                            <td class="td_left">Overall width</td><td>{$width}<td>
                        </tr>
                        <tr>
                            <td class="td_left">Overall depth</td><td>{$depth}<td>
                        </tr>
                        <tr>
                            <td class="td_left">Height</td><td>{$height}<td>
                        </tr>
                    </table>
                </div>
                <div id="product_detail_">
                    {$product_detail}
                </div>
            </div>
            <div class="box_bottom">&nbsp;</div>
            
            <div class="box_top">&nbsp;</div>
            <div id="product_order_frm" class="box_middle">
                <form id="order_frm">
                    <table>
                        <tr>
                            <td class="td_left">Name : </td><td>{$name}<td>
                        </tr>
                        <tr>
                            <td class="td_left">telephone : </td><td>{$tel}<td>
                        </tr>
                        <tr>
                            <td class="td_left">E-mail : </td><td>{$email}<td>
                        </tr>
                    </table>
                </form>
            </div>
            <div class="box_bottom">&nbsp;</div>
        </div>
    </body>
</html>
msg;
	db_close($con);
	
	$headers  = 'MIME-Version: 1.0' . "\r\n";
	$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
	$headers .= "From: $email" . "\r\n" .
		"Reply-To: $email" . "\r\n" .
		'X-Mailer: PHP/' . phpversion();
	
	if(@mail($to, $subject, $message, $headers))
	{
		echo 'success';
	}
	else
	{
		echo 'Can\'t sent message, please try again later.';
	}
?>